package model

import (
	"gluenet/internal/glue-srvm/pkg/gluehttp"
	"time"
)

type Resource struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Type         string    `json:"type"`
	CoresTotal   int       `json:"cores_total"`
	CoresUsed    int       `json:"cores_used"`
	MemoryTotal  int       `json:"memory_total"`
	MemoryUsed   int       `json:"memory_used"`
	StorageTotal int       `json:"storage_total"`
	StorageUsed  int       `json:"storage_used"`
	Status       string    `json:"status"`
	IsFrozen     int       `json:"is_frozen"`
	CreatedAt    time.Time `json:"created_at"`
}

type ResourcePageReq struct {
	Name string `form:"name" json:"name"`
	gluehttp.PageRequest
}

type ResourcePageResp struct {
	Page      gluehttp.PageResponse `json:"page"`
	Resources []Resource            `json:"resources"`
}

type ResourceInfoReq struct {
	ID           string `json:"id"`
	ResourceType string `json:"resource_type"`
}

type ResourceInfoResp struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	ResourceType string   `json:"resource_type"`
	Status       string   `json:"status"`
	Region       string   `json:"region"`
	Tags         []string `json:"tags"`
	IPAddr       string   `json:"ip_addr"`
	Core         int      `json:"core"`
	Memory       int      `json:"memory"`
	Architecture []string `json:"architecture"`
	Image        string   `json:"image"`
	Storage      int      `json:"storage"`
	NetWork      string   `json:"network"`
}

type ResourceBatchOperationReq struct {
	Operation  string   `json:"operation"`
	VMHostsID  []string `json:"vm_hosts"`
	MachinesID []string `json:"machines"`
}

type ResourceBatchOperationResp struct {
	VMHostsID  map[string][]string `json:"vm_hosts"`
	MachinesID map[string][]string `json:"machines"`
}

type VMHostsCreateReq struct {
	Hostname     string   `json:"hostname"`
	Cores        int      `json:"cores"`
	Memory       int      `json:"memory"`
	Architecture string   `json:"architecture"`
	Storage      int      `json:"storage"`
	Interfaces   string   `json:"interfaces"`
	VMHostID     []int    `json:"vmhost_id"`
	Tags         []string `json:"tags"`
}

type MachinesPowerActionReq struct {
	StopMode string `json:"stop_mode"`
	Comment  string `json:"comment"`
}

type TagsUpdateNodesReq struct {
	Add            string `json:"add"`
	Remove         string `json:"remove"`
	Definition     string `json:"definition"`
	RackController string `json:"rack_controller"`
}

type MachinesDeployReq struct {
	SystemID            string `json:"system_id"`
	UserData            string `json:"user_data"`
	Osystem             string `json:"osystem"`
	DistroSeries        string `json:"distro_series"`
	HweKernel           string `json:"hwe_kernel"`
	AgentName           string `json:"agent_name"`
	BridgeAll           bool   `json:"bridge_all"`
	BridgeType          string `json:"bridge_type"`
	BridgeStp           bool   `json:"bridge_stp"`
	BridgeFd            int    `json:"bridge_fd"`
	Comment             string `json:"comment"`
	InstallRackd        bool   `json:"install_rackd"`
	InstallKvm          bool   `json:"install_kvm"`
	RegisterVmHost      bool   `json:"register_vmhost"`
	EphemeralDeploy     bool   `json:"ephemeral_deploy"`
	VcenterRegistration bool   `json:"vcenter_registration"`
	EnableHwSync        bool   `json:"enable_hw_sync"`
}

type VMHostsTagsResp struct {
	Region  map[string]*VMHostsTags `json:"region"`
	Tags    map[string]*VMHostsTags `json:"tags"`
	NetWork map[string]*VMHostsTags `json:"network"`
}

type VMHostsTags struct {
	VMHostID []int `json:"vmhost_id"`
}

type MachinesUpdateReq struct {
	SystemID     string `json:"system_id"`
	Architecture string `json:"architecture"`
	MinHweKernel string `json:"min_hwe_kernel"`
}

type BootResourceResp struct {
	Architecture  []string `json:"architecture"`
	MinimumKernel []string `json:"minimum_kernel"`
}

type BareMachineListResp struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	Tags         []string `json:"tags"`
	Core         int      `json:"core"`
	Memory       int      `json:"memory"`
	Architecture string   `json:"architecture"`
	Image        string   `json:"image"`
	Version      string   `json:"version"`
	Kernel       string   `json:"kernel"`
	Storage      int      `json:"storage"`
	NetWork      string   `json:"network"`
}
